package com.hhd.form.component.input;

import com.hhd.base.utils.CommonUtils;
import com.hhd.form.component.AbstractFieldComponent;
import com.hhd.form.component.ComponentDBFieldType;
import com.hhd.form.entity.DesignFormFieldDefinition;
import com.hhd.form.entity.DesignFormTableFieldMeta;
import org.springframework.stereotype.Component;

@Component
public class InputFieldComponent extends AbstractFieldComponent {

    @Override
    public String getName() {
        return "input";
    }

    @Override
    public ComponentDBFieldType getDBType(DesignFormFieldDefinition field) {
        return ComponentDBFieldType.string;
    }

    @Override
    protected void resolveFieldLength(DesignFormFieldDefinition field, DesignFormTableFieldMeta fieldMeta) {
        if (CommonUtils.isEmpty(field.getLength())) {
            field.setLength(255L);
        }
    }
}
